/**
 * 
 */
package com.vision.sales.cm.db.data;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.sf.gilead.pojo.gwt.LightEntity;

/**
 * @author Mark
 *
 */
@Entity
@Table(name = Check.TABLE)
public class Check extends LightEntity implements Serializable {
	
	private static final long serialVersionUID = 5696948186028424056L;

	public static final String TABLE = "checks"; // NOTE Since "check" is a reserved word, we add an 's'

	public static final String COL_ID ="id";
	public static final String COL_BANK ="bank";
	public static final String COL_CHECK_NO = "check_no";
	public static final String COL_CHECK_DATE = "check_date";
	public static final String COL_AMOUNT ="amount";
	public static final String COL_DATE_DEPOSITED = "date_deposited";
	public static final String COL_DATE_CLEARED ="date_cleared";
	public static final String COL_REMARKS = "remarks";

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "scheck")
	@SequenceGenerator(name = "scheck", sequenceName = "check_seq")
	@Column(name = COL_ID)
	private Long id;

	@Column(name = COL_BANK, nullable = false, updatable = false)
	private String bank;

	@Column(name = COL_CHECK_NO, nullable = false, updatable = false)
	private String checkNo;
	
	@Column(name = COL_CHECK_DATE, nullable = false)
	@Temporal(TemporalType.DATE)
	private Date checkDate;

	@Column(name = COL_AMOUNT, nullable = false)
	private double amount;
	
	@Column(name = COL_DATE_DEPOSITED)
	@Temporal(TemporalType.DATE)
	private Date dateDeposited;

	@Column(name = COL_DATE_CLEARED)
	@Temporal(TemporalType.DATE)
	private Date dateCleared;
	
	@Column(name = COL_REMARKS)
	private String remarks;
	
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	public Check() { } // Serializable support

	@Override
	public boolean equals(Object object) {
		if (object instanceof Check) {
			Check check = (Check) object;
			return getId() != null && getId().equals(check.getId());
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return getId() == null ? super.hashCode() : getId().hashCode();
	}
	
	@Override
	public String toString() {
		return id + ": " + bank + " (" + checkNo + ", " + checkDate + ")";
	}
	
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getBank() {
		return bank;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public String getCheckNo() {
		return checkNo;
	}

	public void setCheckNo(String checkNo) {
		this.checkNo = checkNo;
	}

	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public Date getDateDeposited() {
		return dateDeposited;
	}

	public void setDateDeposited(Date dateDeposited) {
		this.dateDeposited = dateDeposited;
	}

	public Date getDateCleared() {
		return dateCleared;
	}

	public void setDateCleared(Date dateCleared) {
		this.dateCleared = dateCleared;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
}
